package cn.sofwin.ms.dubbo.controller;
import cn.sofwin.core.support.api.GenericStatusCode;
import cn.sofwin.core.support.api.RequestResult;
import cn.sofwin.ms.entity.User;
import cn.sofwin.ms.service.UserService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

    @DubboReference
    UserService userService;

    @GetMapping("/user")
    public RequestResult login(String username,String password){
        RequestResult result=null;
        User user =userService.login(username,password);
        if(user == null){
            result = new RequestResult(GenericStatusCode.ParameterError);

        }else {
            result = new RequestResult();
            result.appendData("user",user);
        }
        return result;
    }
}
